$(function () {
    $("#btnSubmit").on("click", function () {
        var user = $("#userName"),
            password = $("#password");
        if (!user.val()) {
            layer.msg("请输入用户名", {time: 1000});
            return false;
        }
        if (!password.val()) {
            layer.msg("请输入密码", {time: 1000});
            return false;
        }
        $.ajax({
            url: window.jkconfig.webapiurlv + "login",
            type: 'POST',
            data: {
                userName: user.val(),
                passWord: password.val()
            },
            success: function (data) {
                if (data.code == 0) {
                    var token = data.token;
                    localStorage.setItem("api_key", token);
                    localStorage.setItem("userName", user.val());
                    localStorage.setItem("platformId", data.platformId);
                    localStorage.setItem("platformName", data.platformName);
                    window.parent.location.href = 'index.html';
                } else {
                   alert(data.msg);
                }
            }
        });
        return false;
    })
})
    
   

